<link rel="stylesheet" href="/css/style_tabs_generate.css" type="text/css" media="screen">
<script src="/js/jquery-1.js"></script>
<script src="/js/private/generate/index/index.js"></script>
    <script>
        common.setMainTitle('Khởi tạo module');
	  $(document).ready(function(){
		$("a.tab").click(function () {
			$(".active").removeClass("active");
			$(this).addClass("active");
		});
        
		$("div.nextab").click(function () {
			$(".tab").removeClass("active");
			$(this).addClass("active");
		});
	  });
    shortcut.add("Ctrl+S",function() {
        document.frmModuleSettup.submit();
    });
  </script>
  <!-- locate REGION_TemplateHTML| -->
  
<div id="template-zones" style="display:none">
    <div id="template-actions">
        Thêm Action&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;
        <input type="text" name="actionName[]" id="actionNameTemplate" value="" onkeyup="setViewName(this.id,this.value);nextAction(event)"/>
        <a>
            <small>
                <font color="#004FA0">
                    <b>Action</b>
                </font>
            </small>
        </a>
        <span class="add_funtion" onclick="addAction()">&nbsp;+&nbsp;</span>
        <span class="remove_funtion" name="" onclick="removeElement(this.parentNode.id,'actions')">&nbsp;×&nbsp;</span>
    </div>
    <div id="template-properties">
        Tạo thuộc tính &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;
        <input type="text" onkeyup="nextProperty(event);" name="properties[1][]" id="template-input-property" value="" />
        <span class="add_funtion" onclick="addProperty();" >&nbsp;+&nbsp;</span>
        <span class="remove_funtion" name="" onclick="removeElement(this.parentNode.id,'properties')">&nbsp;×&nbsp;</span>
        &nbsp;&nbsp;
        Public <input type="radio" checked="true" id="template-public-checkbox-property" name="properties[1][]" value="public" /> &nbsp;
        Private <input type="radio" id="template-private-checkbox-property" name="properties[1][]" value="private" /> &nbsp;
        Protected <input type="radio" id="template-protected-checkbox-property" name="properties[1][]" value="protected" />
    </div>
    <div id="template-methods">
        Thêm phương thức&nbsp;&nbsp;:&nbsp;
        <input type="text" name="" onkeyup="nextMethod(event);" id="template-input-method" value="" />
        <span class="add_funtion" onclick="addFunction();">&nbsp;+&nbsp;</span>
        <span class="remove_funtion" name="" onclick="removeElement(this.parentNode.id,'methods')">&nbsp;×&nbsp;</span>
        &nbsp;&nbsp;
        Public <input type="radio" checked="true" id="template-public-checkbox-method" name="" value="public" /> &nbsp;
        Private <input type="radio" id="template-private-checkbox-method" name="" value="private" /> &nbsp;
        Protected <input type="radio" id="template-protected-checkbox-method" name="" value="protected" /> &nbsp;
        Static <input type="radio" id="template-static-checkbox-method" name="" value="static" />
    </div>
    <div id="template-views">
        Tên view &nbsp;&nbsp;: <input type="text" name="viewName[]" id="viewNameTemplate" value="" onkeyup="setControllerName(this.value);nextView(event);" />
        <a>
            <small>
                <span id=""></span>
                <font color="#004FA0"><b> .phtml</b> </font>
            </small>
        </a>
        <span class="add_funtion" onclick="addView();">&nbsp;+&nbsp;</span>
        <span class="remove_funtion" name="" onclick="removeElement(this.parentNode.id,'views')">&nbsp;×&nbsp;</span>
    </div>
    <!-- locate REGION_Template_PhanQuyen| -->
    <div style="float:left;" id="template-denies">
        <div class="select" id="role-denyTemplate" >
            <select name="" value="" id="select-deny-template">
                <?php 
                foreach($this->roles as $role){
                ?>
                <option value="<?=$role['CODE']?>"><?=$role['NAME']?></option>
                <?php } ?>
            </select>
        </div>
        <div class="role" id="denyTemplate-Controller1" onclick="selectRole(this.id);">
            IndexController <input type="radio" name="deny[0][]" id="denyTemplate-Controller1-checkbox" value="" />
        </div>
        <?php
        $arrController = $this->moduleInfo['controllers'];
        $controllers = explode(",",$arrController);
        $sttController = 1;
        foreach($controllers as $item){
        if($item != ''){
        $sttController++;
        ?>
            <div class="role" id="denyTemplate-Controller<?=$sttController?>" onclick="selectRole(this.id);">
            <?=$item?>Controller &nbsp;
            <input type="radio" name="" id="denyTemplate-Controller<?=$sttController?>-checkbox" value="<?=$item?>" />
            </div>
        <?php }} ?>
        <span class="add_funtion" onclick="addDeny()">&nbsp;+&nbsp;</span>
        <span class="remove_funtion" name="" onclick="removeElement(this.parentNode.id,'denies')">&nbsp;×&nbsp;</span>
        <script>
            var denyTemplate_Controller = <?=$sttController?>;
        </script>
    </div>
</div>

<div id="tabbed_box_1" class="tabbed_box">
    <div class="tabbed_area">    	
        <ul class="tabs">
            <li><a onclick="disableAllTab();document.getElementById('content_1').style.display='block';" title="content_1" class="tab active">Module</a></li>
            <li><a onclick="disableAllTab();document.getElementById('content_2').style.display='block';" title="content_2" class="tab">Models</a></li>
            <li><a onclick="disableAllTab();document.getElementById('content_3').style.display='block';" title="content_3" class="tab">Controllers</a></li>
            <li><a onclick="disableAllTab();document.getElementById('content_4').style.display='block';" title="content_4" class="tab">View</a></li>
            <li style="display:none"><a onclick="disableAllTab();document.getElementById('content_5').style.display='block';" title="content_5" class="tab">Phân quyền</a></li>
        </ul>
        <?php 
        $trangthai = array(
        'default' => ""
        );
         ?>
        <form name="frmModuleSettup" action="/generate/index/save" method="POST" onload="">
        <?php
        if(isset($this->moduleSelected))
        {
            echo '<input type="hidden" name="isUpdate" value="1" />';
        }
        ?>
            <div style="display: block;" id="content_1" class="content">
            <!-- locate REGION_MODULE| -->
        	<ul>
            	<li>                    
                    <select name="moduleInfo" value="" onchange="selectModule(document.frmModuleSettup)">
                        <option value="">Thêm mới</option>
                        <?php 
                            foreach($this->arrModule as $item){
                                $trangthai[$item] = "";
                                $trangthai[$this->moduleSelected] = "selected='true'";
                                echo '<option value="'.$item.'" '.$trangthai[$item].' >Cập nhật module <b>'.strtoupper($item).'</b></option>';
                            }
                        ?>
                    </select>                   
                    <br />
                </li>
                <script>
                    var moduleName = "<?php
                    if($this->moduleSelected != ''){
                        echo ucfirst($this->moduleSelected);
                    }else{
                        echo 'Default'; 
                    }
                    ?>";
                </script>
                <li>                    
                    Tên gọi &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <input type="text" name="moduleName" value="<?=$this->moduleInfo['name']?>" /> <br />
                </li>
            	<li>
                    Tên hệ thống : <input type="text" name="moduleCreate" value="<?=$this->moduleSelected?>" onKeyUp="setBootstrapName(this.value)" />
                </li>
            	<li>
                    Tự tạo Bootstrap : <input type="checkbox" name="" value="" checked='true' disabled='true' />
                    <small id="bootstrap_name">                        
                    </small>
                    <input type="hidden" name="bootstrapName" id='bootstrapName' value="fff" />
                </li>
            	<li>
                    <div class="actionContent">
                        <div id="nextab" class='button-save-config' onclick="">
                        </div>
                        <div id="messageEmail" class='button-save-message'>
                            Bạn đã lưu thành công
                        </div>
                    </div>
                </li>
			</ul>
        </div>
        <!-- locate REGION_MODEL| -->
        <div style="display: none;" id="content_2" class="content">
            <fieldset>
                <ul id="model1">
                    <li>Tên Model &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 
                    <input type="text" name="modelSingleName" id="modelSingleName" value="" onkeyup="setModelName(this.value)" onBlur="checkModelName(this.value)" />
                    <a>
                        <small>
                            <span id="modelName"></span>
                            <font color="#004FA0">
                                <b> extends</b>
                            </font>
                            <input type="hidden" name="modelName" id="modelCreate" value="" />
                            Zend_Db_Table_Abstract
                        </small>
                    </a>
                    </li>            	
                    <li id="properties">
                        <div id="method1">
                            Tạo thuộc tính &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;
                            <input type="text" onkeyup="nextProperty(event);" name="properties[0][]" id="" value="" />
                            <span class="add_funtion" onclick="addProperty();" >&nbsp;+&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            Public <input type="radio" accesskey="u" checked="true" name="properties[0][]" value="public" /> &nbsp;
                            Private <input type="radio" name="properties[0][]" value="private" /> &nbsp;
                            Protected <input type="radio" name="properties[0][]" value="protected" />
                        </div>
                    </li>
                    <li id="methods">
                        <div id="method1">
                            Thêm phương thức&nbsp;&nbsp;:&nbsp;
                            <input type="text" name="methods[0][]" onkeyup='nextMethod(event);' id="input-method1" value="" />
                            <span class="add_funtion" onclick="addFunction();">&nbsp;+&nbsp;</span>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            Public <input type="radio" checked="true" id="" name="methods[0][]" value="public" /> &nbsp;
                            Private <input type="radio" id="" name="methods[0][]" value="private" /> &nbsp;
                            Protected <input type="radio" id="" name="methods[0][]" value="protected" /> &nbsp;
                            Static <input type="radio" id="" name="methods[0][]" value="static" />
                        </div>
                    </li>
                    <li style="display:none">
                        Tạo đối tượng PDO &nbsp; :&nbsp;<input type="text" name="pdoName" value="" />&nbsp;&nbsp;
                    </li>
                    <li>
                        Tạo phương thức __construct():
                        <input type="checkbox" name="isConstruct" checked='true' value="1" />
                        <small> </small>
                        &nbsp;&nbsp;&nbsp;
                        Tạo Adapter kết nối CSDL
                        <input type="checkbox" name="isAdapterCSDL" checked='true' value="1" />
                    </li>
                    <li>
                        <div class="actionContent">
                            <div id="" class='button-save-config' onclick="">
                            </div>
                            <div id="messageEmail" class='button-save-message'>
                            Bạn đã lưu thành công
                            </div>
                        </div>
                    </li>
                </ul>
            </fieldset>
        </div>
        <!-- locate REGION_CONTROLLER| -->
        <div style="display: none;" id="content_3" class="content">
            <div id="controllers">
                <fieldset>
                    <ul>
                        <li>
                            Tên Controller &nbsp;&nbsp;: <input type="text" name="singleNameController" id="inputControllerName" value="" onBlur="checkControllerName(this.value)"  onkeyup="setControllerName(this.value)" />
                            <a>
                                <small>
                                    <span id="controllerName"></span>
                                    <font color="#004FA0"><b> extends</b> </font>
                                    Zend_Controller_Action
                                </small>
                                <input type="hidden" name="controllerName" id="" value="" />
                            </a>
                            &nbsp;&nbsp;
                            Mô tả Controller &nbsp;&nbsp;: <input type="text" name="controllerDescription" size="40" />                      
                        </li>            	
                        <li id="actions">
                            <div id="action1">
                                Thêm Action&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;
                                <input type="text" name="actionName[]" id="actionName1" value="index" onkeyup="setViewName(this.id,this.value);nextAction(event)" />
                                <a>
                                    <small>
                                        <font color="#004FA0">
                                            <b>Action</b>
                                        </font>
                                    </small>
                                </a>
                                <span class="add_funtion" onclick="addAction()">&nbsp;+&nbsp;</span>
                            </div>
                        </li>
                        <li>
                            <div>                             
                                Chọn Template&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;
                                <select name="templateName" value="" onchange="getListLayout(this.value)">
                                <option value="">--CHỌN--</option>
                                <?php
                                if ($handle = opendir(APPLICATION_PATH.'/templates')) {
                                    while (false !== ($entry = readdir($handle))) {
                                        //$ext = explode(".",$entry);
                                        if($entry != '.' && $entry != '..' && $entry != '.svn'){
                                            echo "<option value='$entry'>$entry</option>";
                                        }
                                    }
                                    closedir($handle);
                                }
                                ?>
                                </select>&nbsp;&nbsp;&nbsp;
                                Chọn Layout
                                <select name="layoutName" id="layoutController">
                                    <option value="default">default</option>
                                </select>
                            </div>
                        </li>
                        <li>Cài đặt phương thức init():
                            <input type="checkbox" checked="true" name="isInit" value="" />
                            <small> </small> &nbsp;&nbsp;&nbsp;Cài đặt nhận dữ liệu request
                            <input type="checkbox" checked="true" name="isGetRequest" value="" />&nbsp;&nbsp;&nbsp;
                            Cài đặt đối tượng model
                            <input type="checkbox" checked="true" name="isCreateModel" value="1" />
                        </li>
                    </ul>
                    <div>
                        <div class="actionContent">
                            <div id="" class='button-save-config' onclick="">
                            </div>
                            <div id="messageEmail" class='button-save-message'>
                            Bạn đã lưu thành công
                            </div>
                        </div>
                    </div>
                </fieldset>
            </div>
            
        </div>
        <!-- locate REGION_VIEW| -->
        <div style="display: none;" id="content_4" class="content">
            <fieldset>
                    <ul>
                        <li id="views">
                            <div id="view1">
                                Tên view &nbsp;&nbsp;: <input type="text" name="viewName[]" id="viewName1" value="index" onkeyup="setControllerName(this.value);nextView(event)" />
                                <a>
                                <small>
                                    <span id="controllerName"></span>
                                    <font color="#004FA0"><b> .phtml</b> </font>
                                </small>
                                </a>
                                <span class="add_funtion" onclick="addView();">&nbsp;+&nbsp;</span>
                            </div>
                        </li>
                    </ul>
                <div>
                    <div class="actionContent">
                        <div id="" class='button-save-config' onclick="document.frmModuleSettup.submit();">
                        </div>
                        <div id="messageEmail" class='button-save-message'>
                        Bạn đã lưu thành công
                        </div>
                    </div>
                </div>
            </fieldset>
        </div>
        <!-- locate REGION_PHANQUYEN| -->
        <div style="display: none;" id="content_5" class="content" style="display:none">
        	<ul>
            	<li>
                    <font color="#004FA0"><b>MODULE NÀY ĐƯỢC CẤP PHÉP CHO :</b></font>
                    <ul>
                        <li>
                        <div style="float:left;">
                            <?php
                                $stt_role = 1;
                                foreach($this->roles as $role){
                            ?>
                            <div class="role" id="role<?=$stt_role?>" onclick="selectRole(this.id);">
                                <?=$role['NAME']?> &nbsp;
                                <input type="checkbox" checked='true' name="alowRoles[]" id="role<?=$stt_role?>-checkbox" value="<?=$role['CODE']?>" />
                            </div>
                            <? 
                            $stt_role++;
                            }
                            ?>
                        </div>
                        </li>
                    </ul>
                </li>
                <li>
                    <font color="#004FA0"><b>NGOẠI TRỪ</b> </font>
                    <ul>
                        <li id="denies">
                            <div style="float:left;padding-bottom:10px;" id="deny1">
                                <div class="select" id="role-deny1" >
                                    <select name="deny[0][]" value="">
                                         <?php 
                                        foreach($this->roles as $role){
                                        ?>
                                        <option value="<?=$role['CODE']?>"><?=$role['NAME']?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <input type="hidden" name="controllerList[]" id="defaultControllerHidden" value="<?=$item?>" />
                                <div class="role" id="deny1-Controller1" onclick="selectRole(this.id);">
                                    indexController &nbsp;
                                    <input type="radio" name="deny[0][]" id="deny1-Controller1-checkbox" value="index" />
                                </div>
                                <?php
                                $sttController1 = 1;
                                foreach($controllers as $item){
                                if($item != ''){
                                $sttController1++;                                
                                ?>
                                    <input type="hidden" name="controllerList[]" id="<?=$item?>hidden" value="<?=$item?>" />
                                    <div class="role" id="deny1-Controller<?=$sttController1?>" onclick="selectRole(this.id);">
                                    <?=$item?>Controller &nbsp;
                                    <input type="radio" name="deny[0][]" id="deny1-Controller<?=$sttController1?>-checkbox" value="<?=$item?>" />
                                </div>
                                <?php }}
                                if($this->moduleSelected){
                                    $path = common::formatPath(APPLICATION_PATH.'/modules/'.$this->moduleSelected.'/models',"/");
                                    if ($handle = opendir($path)) {
                                        while (false !== ($entry = readdir($handle))) {
                                            $model = explode(".",$entry);
                                            $count = count($model);
                                            if($count > 1){
                                                $ext = $model[$count - 1];
                                                if($ext == 'php'){
                                                    $modelName = substr($entry, 0, -4);
                                                    echo '<input type="hidden" id="'.strtolower($modelName).'ModelHidden" value="'.strtolower($modelName).'" />';
                                                }
                                            }
                                        }
                                        closedir($handle);
                                    }
                                }
                                ?>
                                <span class="add_funtion" onclick="addDeny()">&nbsp;+&nbsp;</span>
                            </div>
                        </li>
                    </ul>
                </li>
            	<li>
                    <font color="#004FA0"><b>YÊU CẦU XÁC THỰC</b></font>
                    <ul>
                        <li>
                            <div style="float:left;">
                                <div class="role" id="auth1" onclick="selectRole(this.id);">
                                    Có &nbsp;
                                    <input type="checkbox" checked="true" name="isAuth" id="auth1-checkbox" value="1" />
                                </div>
                            </div>
                        </li>
                    </ul>
                </li>            	
                <li>
                    <font color="#004FA0"><b>ĐƯỜNG DẪN NGOẠI LỆ</b></font>                   
                    <input type="text" size="50" name="exceptionPath" value="/auth/login/accessdenied" />                    
                </li>
            	<li>
                    <br>
                    <br>
                </li>
            	<li>
                    <div class="actionContent">
                        <div id="" class='button-save-config' onclick="document.frmModuleSettup.submit();">
                        </div>
                        <div id="messageEmail" class='button-save-message'>
                        Bạn đã lưu thành công
                        </div>
                    </div>
                </li>
			</ul>
        </div>
        </form>
    </div>
</div>
<br />

<div id="query_builder" style="">
<script>
    // var jxLoadQueryBuider = new Jx();
    // jxLoadQueryBuider.loadInto("query_builder");
    // jxLoadQueryBuider.request("/generate/querybuilder/index","");
</script>
</div>